package com.wondertek.poms.search.controller;

import com.wondertek.poms.common.vo.ResultBean;
import com.wondertek.poms.dao.po.ForCisLog;
import com.wondertek.poms.search.service.IForCisLogESService;
import com.wondertek.poms.search.vo.ForCisLogVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author chenjijiang
 * @description
 */
@RestController
@RequestMapping("forcis-log-es")
@Slf4j
public class ForCisLogESController {

	@Autowired
	private IForCisLogESService iForCisLogESService;


	/**
	 * @param forCisLogVo 未来电视日志vo
	 * @param page        页数
	 * @param start       开始的第一条数
	 * @param rows        记录数
	 * @return 查询的记录
	 */
	@GetMapping("/list")
	public ResultBean list(ForCisLogVo forCisLogVo,
	                       @RequestParam(defaultValue = "1") int page,
	                       @RequestParam(defaultValue = "0") int start,
	                       @RequestParam(defaultValue = "20") int rows) {
		Map<String, String> paramMap = new HashMap<String, String>();
		paramMap.put("endTime", forCisLogVo.getEndTime());
		paramMap.put("startTime", forCisLogVo.getStartTime());
		paramMap.put("prdContId", forCisLogVo.getPrdContId());
		paramMap.put("isFreetrial", forCisLogVo.getIsFreetrial());
		paramMap.put("uuid", forCisLogVo.getUuid());
		paramMap.put("mediaFileId", forCisLogVo.getEndTime());
		paramMap.put("operation", forCisLogVo.getOperation());
		paramMap.put("responseStatus", forCisLogVo.getResponseStatus());
		paramMap.put("auditStatus", forCisLogVo.getAuditStatus());
		List<ForCisLog> forCisLogs = iForCisLogESService.getBcLog(paramMap, start, rows);
		long count = iForCisLogESService.getBcLogCount(paramMap);
		Map<String, Object> map = new HashMap<>();
		map.put("count", count);
		map.put("data", forCisLogs);
		return ResultBean.ok(map);
	}
}
